<template>

  <div class="addMerchantBox" v-loading="loading">
    <el-form ref="form" :model="data">

      <el-form-item label="机构主体全称">
        <el-input v-model="data.company" readonly="readonly" style="width:300px"></el-input>
      </el-form-item>

      <el-form-item label="联系人姓名">
        <el-input v-model="data.real_name" readonly="readonly" style="width:300px"></el-input>
      </el-form-item>

      <el-form-item label="联系手机">
        <el-input v-model="data.mobile" readonly="readonly" style="width:300px"></el-input>
      </el-form-item>

      <el-form-item label="主营类型">
        <el-input v-model="data.main_type" readonly="readonly" style="width:300px"></el-input>
      </el-form-item>

      <el-form-item label="机构类型">
        <span>{{data.organ_type == 1 ? '企业法人' : '个体工商户'}}</span>
      </el-form-item>

      <el-form-item label="营业执照注册号">
        <el-input v-model="data.license_num" readonly="readonly" style="width:300px"></el-input>
      </el-form-item>

      <el-form-item label="省">
        <el-input v-model="data.province_name" readonly="readonly" style="width:300px"></el-input>
      </el-form-item>

      <el-form-item label="市">
        <el-input v-model="data.city_name" readonly="readonly" style="width:300px"></el-input>
      </el-form-item>

      <el-form-item label="区">
        <el-input v-model="data.district_name" readonly="readonly" style="width:300px"></el-input>
      </el-form-item>

      <el-form-item label="详细地址">
        <el-input v-model="data.address" readonly="readonly" style="width:300px"></el-input>
      </el-form-item>

      <el-form-item label="营业范围">
            <el-input
                readonly="readonly"
                style="width:400px"
                type="textarea"
                :autosize="{ minRows: 10}"
                v-model="data.scope">
            </el-input>
      </el-form-item>

      <el-form-item label="营销执照扫描件">
        <img alt class :src="data.license_img" v-show="licenseVisible">
      </el-form-item>

      <el-form-item label="资质证书扫描件">
        <img alt class :src="data.intelligence_img" v-show="intelligenceVisible">
      </el-form-item>

      <el-form-item label="商标授权证件扫描">
        <img alt class :src="data.trademark_img" v-show="trademarkVisible">
      </el-form-item>

      <el-form-item label="银行对公账号">
        <el-input v-model="data.bank_num" readonly="readonly" style="width:300px"></el-input>
      </el-form-item>

      <el-form-item label="对公账号户名">
        <el-input v-model="data.bank_username" readonly="readonly" style="width:300px"></el-input>
      </el-form-item>

      <el-form-item label="对公账号开户行">
        <el-input v-model="data.bank_name" readonly="readonly" style="width:300px"></el-input>
      </el-form-item>

      <el-form-item label="法人代表姓名">
        <el-input v-model="data.person_name" readonly="readonly" style="width:300px"></el-input>
      </el-form-item>

      <el-form-item label="法人身份证号码">
        <el-input v-model="data.person_number" readonly="readonly" style="width:300px"></el-input>
      </el-form-item>

      <el-form-item label="法人身份证正面">
        <img alt class :src="data.person_id_card_z" v-show="cardZVisible">
      </el-form-item>

      <el-form-item label="法人身份证反面">
        <img alt class :src="data.person_id_card_f" v-show="cardFVisible">
      </el-form-item>
    </el-form>

    

    <div class="submitBtnBox">
      <el-button class="submitBtn" @click="submitFn(1)" type="primary">通过</el-button>
      <el-button class="submitBtn" @click="submitFn(2)" type="danger">驳回</el-button>
    </div>

    <div style="height:50px"></div>

    
    <div>
      <el-dialog title="驳回" :visible.sync="dialogFormVisible">
        <el-form :model="dialog">
            <el-form-item label="备注" label-width="60px" style="margin-left:80px">
            <el-input v-model="dialog.remake" style="width:500px" autocomplete="off"></el-input>
            </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button @click="dialogFormVisible = false">取 消</el-button>
            <el-button type="primary" @click="remake">确 定</el-button>
        </div>
    </el-dialog>
  </div>

  </div>

  
  
</template>

<script>
import { truncate } from 'fs';

export default{
    name: 'certification',
    data(){
        return{
            data: {},
            loading: false,
            licenseVisible: true,
            intelligenceVisible: true,
            trademarkVisible: true,
            cardZVisible: true,
            cardFVisible: true,
            dialogFormVisible: false,
            dialog: {
                remake: ''
            },
            formLabelWidth: '120px'
        }
    },
    methods: {

        //获取认证信息
        getParentViewData(){

            this.loading = true;
            this.$http.post("/web/agent/info", {
                    token : localStorage.getItem("user_token"),
                    id: this.$route.query.id
            }).then(response => {
                if (response.data.status == 'success') {
                    this.data = response.data.data
                }
                this.loading = false
            }).catch(error => {
                this.loading = false
            });

        },

        remake(){
            this.loading = true;
            this.dialogFormVisible = false;
            this.$http.post("/web/agent/exam", {
                remake: this.dialog.remake,
                status: 2,
                token: localStorage.getItem('user_token'),
                id: this.data.id
            }).then(response => {
                if (response.data.status == 'success') {
                    this.$message({
                        message: '审核成功',
                        type: 'success',
                        duration: 6000
                    });

                    this.$router.push({name: 'checkProve'})
                }else{
                    this.$message({
                        showClose: true,
                        message: '审核失败',
                        type: 'error'
                    });
                }
                    this.loading = false
                }).catch(error => {
                    this.$message({
                        showClose: true,
                        message: '审核失败，请稍候再试',
                        type: 'error'
                    });
                    this.loading = false
            });
        },

        //提交信息
        submitFn(value){

            if (value == 2) {
                this.dialogFormVisible = true;
                return;
            }
            

            this.loading = true;

            this.$http.post("/web/agent/exam", {
                status:value,
                token: localStorage.getItem('user_token'),
                id: this.data.id
            }).then(response => {

                if (response.data.status == 'success') {
                    this.$message({
                        message: '审核成功',
                        type: 'success',
                        duration: 6000
                    });
                    this.$router.push({name: 'checkProve'})
                }else{
                    this.$message({
                        showClose: true,
                        message: '审核失败',
                        type: 'error'
                    });
                }
                    this.loading = false
                }).catch(error => {
                    this.$message({
                        showClose: true,
                        message: '审核失败，请稍候再试',
                        type: 'error'
                    });
                    this.loading = false
            });
            
        }
    },
    mounted() {
        this.getParentViewData();
    }
    
}

</script>

<style scoped lang="scss">
@import "./check.scss";
</style>